package com.mtgdeckbuilder.server.transformer;

import com.mtgdeckbuilder.server.entity.Card;
import com.mtgdeckbuilder.shared.dto.CardDTO;

public class CardTransformer {

   public static CardDTO entityToDto(final Card entity) {
      final CardDTO dto = new CardDTO();
      dto.setArtist(entity.getArtist());
      dto.setCost(entity.getCost());
      dto.setEdition(entity.getEdition());
      dto.setMultiverseId(entity.getMultiverseId());
      dto.setName(entity.getName());
      for (final String otherEdition : entity.getOtherEditions()) {
         dto.getOtherEditions().add(new String(otherEdition));
      }
      dto.setText(entity.getText());
      dto.setType(entity.getType());
      return dto;
   }

   public static Card dtoToEntity(final CardDTO dto) {
      final Card entity = new Card();
      entity.setArtist(dto.getArtist());
      entity.setCost(dto.getCost());
      entity.setEdition(dto.getEdition());
      entity.setMultiverseId(dto.getMultiverseId());
      entity.setName(dto.getName());
      for (final String otherEdition : dto.getOtherEditions()) {
         entity.getOtherEditions().add(new String(otherEdition));
      }
      entity.setText(dto.getText());
      entity.setType(dto.getType());
      return entity;
   }

}
